<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改商城店铺信息')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-shop-edit" th:object="${jiajiaMallShopInformation}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">店铺名字：</label>
                <div class="col-sm-8">
                    <input name="shopName" th:field="*{shopName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">工商登记号：</label>
                <div class="col-sm-8">
                    <input name="shopCertNo" th:field="*{shopCertNo}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">负责人：</label>
                <div class="col-sm-8">
                    <input name="legalName" th:field="*{legalName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">负责人证件号：</label>
                <div class="col-sm-8">
                    <input name="legalCertNo" th:field="*{legalCertNo}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">负责人电话：</label>
                <div class="col-sm-8">
                    <input name="legalPhone" th:field="*{legalPhone}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">负责人户籍地址：</label>
                <div class="col-sm-8">
                    <input name="legalRegisteredAddress" th:field="*{legalRegisteredAddress}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">负责人居住地址：</label>
                <div class="col-sm-8">
                    <textarea name="legalResidentialAddress" class="form-control" required>[[*{legalResidentialAddress}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">账户开户行：</label>
                <div class="col-sm-8">
                    <input name="openingBank" th:field="*{openingBank}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">店铺图片：</label>
                <div class="col-sm-8">
                    <div class="file-loading">
                        <input id="file" class="form-control" accept="image/jpg,image/jpeg,image/png" name="file"  type="file">
                        <img th:src="*{photoUrl}" style="width: 80px ;height: auto;" src="" id="imgPhoto"  />
                        <input th:field="*{photoUrl}" id="photoUrl" class="form-control" name="photoUrl"   type="text" style="display:none">
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">店铺主页图片：</label>

                <div class="col-sm-8">
                    <div class="file-loading">
                        <input id="file2" class="form-control" accept="image/jpg,image/jpeg,image/png" name="file"  type="file">
                        <img th:src="*{photoUrls}" style="width: 80px ;height: auto;" src="" id="imgPhotos"  />
                        <input th:field="*{photoUrls}" id="photoUrls" class="form-control" name="photoUrls"   type="text" style="display:none">
                    </div>
                </div>

            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">收款账户：</label>
                <div class="col-sm-8">
                    <input name="accountNumber" th:field="*{accountNumber}" class="form-control" type="text" required>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">店铺状态：</label>
                <div class="col-sm-8">
                    <select name="shopStatus" class="form-control m-b" th:with="type=${@dict.getType('shop_status')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{shopStatus}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">店铺等级：</label>
                <div class="col-sm-8">
                    <input name="shopLevel" th:field="*{shopLevel}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "mall/shop";
        $("#form-shop-edit").validate({
            focusCleanup: true
        });



        $("input[name='joiningStartTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-shop-edit').serialize());
            }
        }

        function uploadFile(idSelector,callback) {
            var formData = new FormData();
            formData.append('file',$(idSelector)[0].files[0]);
            $.modal.loading("图片上传中，请稍后...")
            $.ajax({
                url: "/common/admin/upload/up/single",
                data: formData,
                type: "post",
                dataType: "json",
                processData: false,
                contentType: false,
                success: function(result) {
                    $.modal.closeLoading();
                    callback(result)
                }
            })
        }



        $("#file").bind('change', function () {
            $("#imgPhoto").show();
            $("#imgPhoto").attr("src",URL.createObjectURL($(this)[0].files[0]));

            uploadFile("#file",function (res1) {
                $("#photoUrl").val(res1.url);

            })
        });

        $("#file2").bind('change', function () {
            $("#imgPhotos").show();
            $("#imgPhotos").attr("src",URL.createObjectURL($(this)[0].files[0]));
            uploadFile("#file2",function (res1) {
                $("#photoUrls").val(res1.url);
            })
        });


    </script>
</body>
</html>